package cn.tedu.csmall.stock.webapi.config;

import cn.tedu.csmall.stock.webapi.quartz.QuartzJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//编写调度绑定关系
public class QuartzConfig {

    @Bean
    public JobDetail showTime(){

        return JobBuilder.newJob(QuartzJob.class)
                .withIdentity("dataTime")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger showTimeTrigger(){
        CronScheduleBuilder cron
                = CronScheduleBuilder.cronSchedule("0/10 * * * * ?");
        return TriggerBuilder.newTrigger()
                .forJob(showTime())
                .withIdentity("dataTimeTrigger")
                .withSchedule(cron)
                .build();
    }
}
